<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <h3>看看你出生几天了</h3>
    <label for="startDate">启始日期</label>
    <input type="date" id="startDate" value="1983-04-03" placeholder="启始日期">
    <label for="endDate">结束日期</label>
    <input type="date" id="endDate" placeholder="结束日期">
    <div id="show">

    </div>
    <script>
        var startDate, endDate, startValue, endValue, dayValue,show;
        startDate = document.getElementById('startDate');
        endDate = document.getElementById('endDate');
        endDate.onblur = function () {
            startValue = new Date(startDate.value);
            endValue = new Date(endDate.value)
            dayValue = endValue.getTime() - startValue.getTime();
            show = document.getElementById('show');
            show.innerHTML = '到今天为止，您总共活了：'+dayValue/1000/60/60/24 + "天";
            console.log(dayValue/1000/60/60/24)
        }
    </script>
</body>

</html>